#import "DDZFModel.h"
#import "DDCouponsModel.h"
#import "DDFSModel.h"
@implementation DDZFModel
+ (DDZFModel *)modelWithDict:(NSDictionary *)dict
{
   DDZFModel *model = [[DDZFModel alloc] init];
    [model setValuesForKeysWithDictionary:dict];
    return model;
}
- (void)setValue:(id)value forKey:(NSString *)key
{
    if ([key isEqualToString:@"coupons"] || [key isEqualToString:@"discoupons"])
    {
        NSMutableArray <DDCouponsModel *>* array = [NSMutableArray array];
        for (NSDictionary *dict in value)
        {
            if ([dict isKindOfClass:[NSDictionary class]])
            {
                DDCouponsModel *coupons = [[DDCouponsModel alloc] init];
                [coupons setValuesForKeysWithDictionary:dict];
                [array addObject:coupons];
            }
        }
        [super setValue:array forKey:key];
    }
    else if ([key isEqualToString:@"paychannels"])
    {
        NSMutableArray <DDFSModel *>* array = [NSMutableArray array];
        for (NSDictionary *dict in value)
        {
            if ([dict isKindOfClass:[NSDictionary class]])
            {
                DDFSModel *fs = [[DDFSModel alloc] init];
                [fs setValuesForKeysWithDictionary:dict];
                [array addObject:fs];
            }
        }
        [super setValue:array forKey:@"fs"];
    }
    else if ([key isEqualToString:@"vipdiscount"] || [key isEqualToString:@"gamediscount"])
    {
        NSString * new_value = [NSString stringWithFormat:@"%.1f",[value floatValue] * 0.1];
        [super setValue:new_value forKey:key];
    }
    else
    {
        [super setValue:value forKey:key];
    }
}
- (void)setValue:(id)value forUndefinedKey:(NSString *)key
{
}

@end
